{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#!/usr/bin/env python\n",
    "# -*- coding: utf-8 -*-\n",
    "\n",
    "__author__ = 'Michael Liao'\n",
    "\n",
    "from models import User, Blog, Comment\n",
    "\n",
    "from transwarp import db\n",
    "\n",
    "db.create_engine(user='www-data', password='www-data', database='awesome')\n",
    "\n",
    "u = User(name='Test', email='test@example.com', password='1234567890', image='about:blank')\n",
    "\n",
    "u.insert()\n",
    "\n",
    "print 'new user id:', u.id\n",
    "\n",
    "u1 = User.find_first('where email=?', 'test@example.com')\n",
    "print 'find user\\'s name:', u1.name\n",
    "\n",
    "u1.delete()\n",
    "\n",
    "u2 = User.find_first('where email=?', 'test@example.com')\n",
    "print 'find user:', u2"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
